<?php

namespace App\Http\Controllers\Api;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Models\Ads\Ad;
use App\Models\Shop\Good;

class HomeController extends Controller
{
    /***
     * 商城首页
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function index()
    {
        //首页焦点图
        $sidles = Ad::where('category_id', 1)->orderBy('sort_order')->get();

        //首页banner图
        $banners = Ad::where('category_id', 2)->orderBy('sort_order')->get();

        //推荐商品
        $goods = Good::where('is_recommend', 1)->where('is_onsale', 1)->orderBy('sort_order')->get();

        return compact('sidles', 'banners', 'goods');
    }
}
